package com.yanqu.road.utils;

public class RandomSeedHelper {

    //随机种子
    private int randomSeed;

    public RandomSeedHelper(int randomSeed) {
        this.randomSeed = randomSeed;
    }

    /**
     * 只能随机整数
     */
    public long random(int min, int max) {
        this.randomSeed = (214013 * this.randomSeed + 2531011) & 0x7fffffff;
        return min + this.randomSeed % (max - min + 1);
    }

    /**
     * 摇骰子，判断概率(千分比)
     */
    public boolean roll(int probability) {
        if (this.random(0, 999) < probability) {
            return true;
        }
        return false;
    }
}
